/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thuan.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "UserAccount")
public class UserAccount implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "user_name")
    private String username;
    
    @Column(name = "password")
    private String password;
    
    @Column(name = "name")
    private String name;
    
    @Column(name = "score")
    private int score;
    
    @Column(name = "win")
    private int win;
    
    @Column(name = "lose")
    private int lose;
    
    @Column(name = "signin_time")
    @Temporal(TemporalType.DATE)
    private Date signinTime;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "playerA")
	private Set<Competition> competitionsForPlayerA = new HashSet<Competition>();
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "playerB")
	private Set<Competition> competitionsForPlayerB = new HashSet<Competition>();
    
    @OneToMany(fetch = FetchType.LAZY, mappedBy = "winner")
	private Set<Competition> competitionsForWinner = new HashSet<Competition>();
    
    @ManyToMany(cascade = {CascadeType.ALL})
    @JoinTable(name="LeagueMember", 
                joinColumns={@JoinColumn(name="player_id")}, 
                inverseJoinColumns={@JoinColumn(name="league_id")})
    private Set<League> leagues = new HashSet<League>();
    
    
    public UserAccount() {
    }

    public UserAccount(String username, String password, String name, int score, int win, int lose, Date signinTime) {
        this.username = username;
        this.password = password;
        this.name = name;
        this.score = score;
        this.win = win;
        this.lose = lose;
        this.signinTime = signinTime;
    }

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	public int getWin() {
		return win;
	}

	public void setWin(int win) {
		this.win = win;
	}

	public int getLose() {
		return lose;
	}

	public void setLose(int lose) {
		this.lose = lose;
	}

	public Date getSigninTime() {
		return signinTime;
	}

	public void setSigninTime(Date signinTime) {
		this.signinTime = signinTime;
	}

	public Set<Competition> getCompetitionsForPlayerA() {
		return competitionsForPlayerA;
	}

	public void setCompetitionsForPlayerA(Set<Competition> competitionsForPlayerA) {
		this.competitionsForPlayerA = competitionsForPlayerA;
	}

	public Set<Competition> getCompetitionsForPlayerB() {
		return competitionsForPlayerB;
	}

	public void setCompetitionsForPlayerB(Set<Competition> competitionsForPlayerB) {
		this.competitionsForPlayerB = competitionsForPlayerB;
	}

	public Set<Competition> getCompetitionsForWinner() {
		return competitionsForWinner;
	}

	public void setCompetitionsForWinner(Set<Competition> competitionsForWinner) {
		this.competitionsForWinner = competitionsForWinner;
	}
}
